package com.un.ebs.inventory.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.un.ebs.core.enums.IEnum;
import lombok.Getter;

/**
 * @author liubo
 * @email liubocs@163.com
 * @date 2020/5/23 23:01
 */
@Getter
public enum InventoryTypeEnum implements IEnum {

    /**
     * 入库
     */
    IN(0, "入库"),

    /**
     * 出库
     */
    OUT(1, "出库"),

    /**
     * 移库
     */
    MOVE(2, "移库"),

    /**
     * 销售订单
     */
    SALE(10, "销售订单"),

    /**
     * 生产订单
     */
    PRODUCTION(11, "生产订单"),

    /**
     * 服务订单
     */
    SERVICE(12, "服务订单"),

    /**
     * 采购订单
     */
    PURCHASE(19, "采购订单"),

    /**
     * 销售合同
     */
    CONTRACT_SALE(20, "销售合同"),

    /**
     * 采购合同
     */
    CONTRACT_PURCHASE(21, "采购合同"),
    CONTRACT_SERVICE(22, "质保服务"),
    CONTRACT_TRIAL_PRODUCTION(23, "科研项目"),
    CONTRACT_REPAIR(24, "维修合同"),
    CONTRACT_OEM(25, "代工合同"),

    // 入库
    ACCOUNT_INIT(60, "期初入库"),
    PURCHASE_IN(30, "采购入库单"),
    PRODUCTION_IN(40, "生产入库单"),
    CHECK_IN(61, "盘盈入库"),
    MOVE_IN(31, "调拨入库"),

    // 出库
    PRODUCTION_BOM_USER(41, "生产领料单"),
    PRODUCTION_USER(42, "耗材领用单"),
    REPAIR_USER(43, "维修领料单"),
    SALE_OUT(50, "销售出库单"),
    TECH_OUT(51, "科研材料出库单"),
    CHECK_OUT(62, "盘亏出库"),
    MOVE_OUT(32, "调拨出库"),

    //发票
    INVOICE_PURCHASE(70, "采购发票"),
    INVOICE_SALE(71, "销售发票"),

    NotDefine(99, "未定义");


    @EnumValue
    private final int code;
    private final String desc;

    InventoryTypeEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static InventoryTypeEnum valueOf(int code) {
        for (InventoryTypeEnum e : InventoryTypeEnum.values()) {
            if (e.getCode() == code) {
                return e;
            }
        }
        return null;
    }
}
